//
//  ZBMoBanEightHeadView.m
//  MoBan
//
//  Created by apple on 16/7/18.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ZBMoBanEightHeadView.h"
#import "ZBMoBanEightLineView.h"
@interface ZBMoBanEightHeadView()<ZBMoBanEightLineViewDeleget>
@property(nonatomic,strong)UIButton *loginbutten;
@property(nonatomic,strong)UIButton *setButten;
@property(nonatomic,strong)ZBMoBanEightLineView *lineview;

@property(nonatomic,strong)NSMutableArray *array;
@end
@implementation ZBMoBanEightHeadView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addUI];
    }
    return self;
}
-(void)addUI
{
    self.loginbutten = [[UIButton alloc]init];
    [self.loginbutten setTitle:@"点击登录" forState:UIControlStateNormal];
    [self.loginbutten setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.loginbutten addTarget:self action:@selector(btnClic:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.loginbutten];
    
    self.setButten = [[UIButton alloc]init];
    [self.setButten setTitle:@"设置" forState:UIControlStateNormal];
    [self.setButten setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.setButten addTarget:self action:@selector(btnClic:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.setButten];
    
    self.lineview = [[ZBMoBanEightLineView alloc]init];
    self.lineview.deleget = self;
    [self addSubview:self.lineview];

}
-(NSMutableArray<ZBButtenDataSouce *> *)ZBLineViewIteamCount
{
    return self.array;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.loginbutten.frame = CGRectMake(self.width/2-50*Kscr, 80*Kscr, 100*Kscr, 40*Kscr);
    self.loginbutten.layer.borderWidth = 1;
    self.loginbutten.layer.borderColor = [UIColor grayColor].CGColor;
    self.setButten.frame = CGRectMake(self.width-80*Kscr, 160*Kscr, 40*Kscr, 40*Kscr);
    self.setButten.layer.borderWidth = 1;
    self.setButten.layer.borderColor = [UIColor grayColor].CGColor;

    self.lineview.frame = CGRectMake(0, self.height-40*Kscr, self.width, 40*Kscr);
}
-(void)ZBSetDatasouce:(NSString *)str
{
    NSMutableArray *muarray = [NSMutableArray array];
    
    for (NSInteger i=0; i<5; i++) {
        ZBButtenDataSouce *array = [[ZBButtenDataSouce alloc]init];
        array.name = @"哈哈" ;
        array.namecount = @"1";
        [muarray addObject:array];
    }
    
    self.array = muarray;
    
    [self.lineview reloadData];
}
-(void)ZBLineView:(ZBMoBanEightLineView *)lineview didSelectindex:(NSInteger)inter
{
    
    if ([self.deleget respondsToSelector:@selector(ZBDidSelectedAtIndex:)]) {
        [self.deleget ZBDidSelectedAtIndex:inter];
    }
    NSLog(@"%ld",inter);

}
-(void)btnClic:(UIButton *)butten
{
    if ([self.deleget respondsToSelector:@selector(ZBBtnClic:)]) {
        [self.deleget ZBBtnClic:butten];
    }
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
